from building import *

objs = Glob("src/*.c") + Glob("src/*.cpp")

libsForSimulator = {
    "Can": Glob("src/config/Can_Cfg.c"),
}


@register_library
class LibrarySimulator(Library):
    def config(self):
        if IsBuildForMSVC():
            self.LIBS = ["CanLib", "RS232", "Utils"]
        else:
            self.LIBS = ["CanLib", "DevLib", "Utils"]
        self.CPPPATH = ["$INFRAS", "$StdTrace_Cfg", "#RingBuffer"]
        self.source = objs
        for libName, cfg in libsForSimulator.items():
            self.LIBS += [libName]
            self.RegisterConfig(libName, cfg)
            self.CPPPATH += ["$%s_Cfg" % (libName)]
            self.Append(CPPDEFINES=["USE_%s" % (libName.split(":")[0].upper())])
        if IsBuildForMSVC():
            self.LIBS += ["User32"]


objsFlsAc = Glob('src/FlsAc.c') + Glob('src/critical.c')


@register_library
class LibraryFlsAc(Library):
    def config(self):
        self.CPPPATH = ['$INFRAS']
        self.source = objsFlsAc

objsCritical = Glob('src/critical.c')

@register_library
class LibraryCritical(Library):
    def config(self):
        self.CPPPATH = ['$INFRAS']
        self.source = objsCritical
